﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Common;
using Persistence.Dao;
using Domain;
using Persistence;
namespace web.manage
{
    public partial class qqonline_operate : adminBase
    {
        int id = DNTRequest.GetQueryInt("id", 0);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (id > 0)
                {
                    QqOnline entity_QqOnline = Singleton<QqOnlineDao>.Instance.GetModel(id);
                    if (entity_QqOnline != null)
                    {
                        ViewState["entity_QqOnline"] = entity_QqOnline;
                        txt_QqOnline_name.Value = entity_QqOnline.name;
                        txt_QqOnline_qqNumber.Value = entity_QqOnline.qqNumber;
                        txt_QqOnline_qqOrder.Value = entity_QqOnline.qqOrder.ToString();
                    }
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            QqOnline entity_QqOnline = new QqOnline();
            if (id > 0 && ViewState["entity_QqOnline"] != null)
            {
                entity_QqOnline = (QqOnline)ViewState["entity_QqOnline"];
            }
            entity_QqOnline.name = txt_QqOnline_name.Value.Trim();
            entity_QqOnline.qqNumber = txt_QqOnline_qqNumber.Value.Trim();
            entity_QqOnline.qqOrder = Utils.ObjectToInt32(txt_QqOnline_qqOrder.Value.Trim(), 0);
            bool bResult = false;
            if (id > 0)
            {
                bResult = Singleton<QqOnlineDao>.Instance.Update(entity_QqOnline);
            }
            else
            {
                try
                {
                    Singleton<QqOnlineDao>.Instance.Insert(entity_QqOnline);
                    bResult = true;
                }
                catch { }
            }
            if (bResult)
            {
                Message.alert("操作成功");
                txt_QqOnline_name.Value = "";
                txt_QqOnline_qqNumber.Value = "";
                txt_QqOnline_qqOrder.Value = "";
            }
            else
            {
                Message.alert("操作失败，请检查您的数据");
            }
        }
    }
}
